package ex2.factoryMode;

import java.util.Scanner;

public class FactoryModeClient {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		boolean flag=true;
		while(flag) {
			System.out.print("1.Bread\n2.Milk\n0.exit\n请输入需要产品前的序号，回车确认：");
			String input;
			char select;
			input=scanner.next();
			select=input.charAt(0);
			switch(select) {
			case '1':{
				IFood food=Factory.getInstance("Bread");
				if(food!=null)food.eat();
			}break;
			case '2':{
				IFood food=Factory.getInstance("Milk");
				if(food!=null) food.eat();
			}break;
			case '0':{
				flag=false;
				System.out.println("退出程序！");
			}break;
			default:System.out.println("输入有误，请重新选择！");
			}
		}
	}
}
